package com.Cychat.commons.entity;

import java.util.Date;

/**
 * Auther: 刘博文
 * Date: 2025/10/28:13:59
 * Description: 统一消息返回体
 */
public class ResultMessage<T> {
    private Integer code;
    private String message;
    private T data;
    private Date timestamp;

    public ResultMessage() {
        timestamp = new Date();
    }

    public ResultMessage(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        timestamp = new Date();
    }

    public static <T> ResultMessage<T> success(T data) {
        return new ResultMessage<>(200, "success", data);
    }

    public static <T> ResultMessage<T> success() {
        return success(null);
    }

    public static <T> ResultMessage<T> error(String message) {
        return new ResultMessage<>(500, message, null);
    }

    public Integer getCode() {
        return code;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
